package com.faxsun.web.endpoint.entity;

import java.util.Date;

import mblog.web.formatter.JsonUtils;

import com.faxsun.core.persist.entity.LiveMsgPO;
import com.faxsun.core.persist.entity.LivePO;

/**
 * 直播消息的Json格式
 * 
 * @author songdragon 2015年6月18日
 *
 */
public class LiveMsgJSON {

	public Long id;
	public LiveMsgContent content;
	public UserJSON user;
	public Long channelId;
	public Date date;
	public int thumbsup;
	public int comments;

	public static LiveMsgJSON parse(LiveMsgPO po) {
		LiveMsgJSON json = new LiveMsgJSON();
		json.id = po.getId();
	    LivePO channel = po.getChannel();
		json.channelId = channel.getId();
		json.date = po.getDate();
		json.user = UserJSON.parse(po.getSender());
		json.content = LiveMsgContent.parse(po.getContent());
		json.thumbsup=po.getThumbsup();
		json.comments=po.getComments();
		return json;
	}

	public static String toJson(LiveMsgJSON o) {
		return JsonUtils.toJson(o);
	}

	public String toString() {
		return toJson(this);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public LiveMsgContent getContent() {
		return content;
	}

	public void setContent(LiveMsgContent content) {
		this.content = content;
	}

	public UserJSON getUser() {
		return user;
	}

	public void setUser(UserJSON user) {
		this.user = user;
	}

	public Long getChannelId() {
		return channelId;
	}

	public void setChannelId(Long channelId) {
		this.channelId = channelId;
	}

	/*
	 * public Date getDate() { return date; }
	 */

	public long getDate() {
		if (date != null) {
			return date.getTime();
		} else
			return 0;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public int getThumbsup() {
		return thumbsup;
	}

	public void setThumbsup(int thumbsup) {
		this.thumbsup = thumbsup;
	}

	public int getComments() {
		return comments;
	}

	public void setComments(int comments) {
		this.comments = comments;
	}

}
